<template>
    <div class="son">
        <h3>我是儿子曹植：{{ money }}</h3>
        <button @click="handler($parent)">点击我爸爸给我10000元</button>
    </div>
</template>

<script setup lang="ts">
import { ref } from 'vue';

let money = ref(666);  //儿子的钱数
const fly = () => {
    console.log('我可以飞');
}
const handler = ($parent: any) => {
    money.value += 10000;
    $parent.money -= 10000;
}
//组件内部数据对外关闭的，别人不能访问
//如果想让外部访问需要通过defineExpose方法对外暴露
defineExpose({
    money,
    fly
})
</script>

<style scoped>
.son {
    width: 300px;
    height: 200px;
    background: cyan;
}
</style>